package sist.core.board;

import java.util.List;

import sist.bean.BoardBean;
import sist.util.ServiceUtil;

import com.ibatis.sqlmap.client.SqlMapClient;

public class BoardDao {
	static SqlMapClient sqlMapper;

	static {
		sqlMapper = ServiceUtil.getSqlMapClient();
		System.out.println(sqlMapper);
	}
	
	public static void boardInsert(BoardBean bean) throws Exception {
		sqlMapper.insert("boardInsert", bean);
	}
	
	public static List<BoardBean> selectAll() throws Exception {
		return sqlMapper.queryForList("selectAll");
	}
	
	public static void updateBoard(int no) throws Exception{
		sqlMapper.update("updateBoard", no);
	}
	
	public static Object infoBoard(int no) throws Exception{
		return sqlMapper.queryForObject("infoBoard", no);
	}
	
	public static Object getPassWord(int no) throws Exception{
		return sqlMapper.queryForObject("getPassWord", no);
	}
	
	public static boolean loginCheck(String id, String pass) throws Exception {
		//System.out.println(sqlMapper);
		String dbPass = (String)sqlMapper.queryForObject("loginCheck", id);
		if(dbPass == null || dbPass.equals("")){
			return false;
		}else {
			if(dbPass.equals(pass)){
				return true;
			} else{
				return false;
			}		
		}
	}
	
	public static void deleteBoard(int no) throws Exception{
		sqlMapper.delete("deleteBoard", no);
	}
	
	public static void modifyBoard(BoardBean bean) throws Exception{
		sqlMapper.update("modifyBoard", bean);
	}
	
}
